<%--
  Created by IntelliJ IDEA.
  User: pc
  Date: 2025/1/5
  Time: 15:19
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html lang="zh-CN">
<head>
    <title>我的音乐</title>
    <link rel="stylesheet" href="<%=request.getContextPath()%>/static/plugins/bootstrap-4.6.2-dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/static/plugins/bootstrap-icons-1.11.3/font/bootstrap-icons.min.css">
</head>
<body>

<div class="row">
    <div class="col-1"></div>
    <div class="col-10">
        <table class="table table-hover shadow-lg">
            <thead>
            <tr>
                <th scope="col">songId</th>
                <th scope="col">名称</th>
                <th scope="col">简介</th>
                <th scope="col">分类</th>
                <th scope="col">uploaderId</th>
                <th scope="col">操作</th>
            </tr>
            </thead>
            <tbody>
            <%
                int count = (int) request.getAttribute("countNum");
                // 计算总页数
                int pageCount = 0;
                if(count % 2 == 0){
                    pageCount = count / 2;
                }else {
                    pageCount = count / 2 + 1;
                }
                //获取页码
                int pageNo = (int) request.getAttribute("pageNo");
            %>
            <c:forEach items="${requestScope.songs}" var="songs" varStatus="status">
                <tr>
                    <th scope="row">${songs.songId}</th>
                    <td>${songs.title}</td>
                    <td>${songs.description}</td>
                    <td>${songs.categoryId}</td>
                    <td>${songs.uploaderId}</td>
                    <td>
                        <i class="bi bi-pen-fill mr-1" data-toggle="modal" data-target="#exampleModal${songs.songId}">修改</i>
                        <a href="<%=request.getContextPath()%>/song/songRemoveById?id=${songs.songId}"><i class="bi bi-trash3-fill mr-1">删除</i></a>
                        <i class="bi bi-eye-fill mr-1" >查看</i>
                    </td>
                </tr>
            </c:forEach>
            </tbody>
        </table>
    </div>
    <div class="col-1"></div>
</div>


<div class="row">
    <div class="col-1"></div>
    <div class="col-10">
        <nav aria-label="Page navigation example">
            <ul class="pagination float-right">
                <c:if test="${requestScope.pageNo == 1}">
                    <li class="page-item disabled"><a class="page-link" href="<%=request.getContextPath()%>/musicFindByPageServlet?flag=0&pageNo=${requestScope.pageNo}&pageSize=2">上一页</a></li>
                </c:if>
                <c:if test="${requestScope.pageNo != 1}">
                    <li class="page-item"><a class="page-link" href="<%=request.getContextPath()%>/musicFindByPageServlet?flag=0&pageNo=${requestScope.pageNo}&pageSize=2">上一页</a></li>
                </c:if>
                <%--          <li class="page-item"><a class="page-link" href="<%=request.getContextPath()%>/userFindByPageServlet?flag=0&pageNo=${requestScope.pageNo}&pageSize=2">上一页</a></li>--%>
                <li class="page-item"><a class="page-link" href="#">1</a></li>
                <li class="page-item"><a class="page-link" href="#">2</a></li>
                <li class="page-item"><a class="page-link" href="#">3</a></li>
                <c:if test="<%=pageCount <= pageNo%>">
                    <li class="page-item disabled"><a class="page-link" href="<%=request.getContextPath()%>/musicFindByPageServlet?flag=1&pageNo=${requestScope.pageNo}&pageSize=2">下一页</a></li>
                </c:if>
                <c:if test="<%=pageCount > pageNo%>">
                    <li class="page-item"><a class="page-link" href="<%=request.getContextPath()%>/musicFindByPageServlet?flag=1&pageNo=${requestScope.pageNo}&pageSize=2">下一页</a></li>
                </c:if>
                <%--            <li class="page-item"><a class="page-link" href="<%=request.getContextPath()%>/userFindByPageServlet?flag=1&pageNo=${requestScope.pageNo}&pageSize=2">下一页</a></li>--%>
            </ul>
        </nav>
    </div>
    <div class="col-1"></div>
</div>

<script src="<%=request.getContextPath()%>/static/plugins/jquery/jquery.slim.min.js"></script>
<script src="<%=request.getContextPath()%>/static/plugins/bootstrap-4.6.2-dist/js/bootstrap.bundle.js"></script>
</body>
</html>
